﻿/*
 * ©2009-2010 XELF
 * http://xelf.info
 */

namespace XELF.Framework {

	public partial struct Vector2 {
		/// <summary>
		/// 距離
		/// </summary>
		public static float Distance(Vector2 a, Vector2 b) {
			Vector2 d;
			Subtract(ref a, ref b, out d);
			return d.Length();
		}
	}

	public partial struct Vector3 {
		/// <summary>
		/// 距離
		/// </summary>
		public static float Distance(Vector3 a, Vector3 b) {
			Vector3 d;
			Subtract(ref a, ref b, out d);
			return d.Length();
		}
	}

	public partial struct Vector4 {
		/// <summary>
		/// 距離
		/// </summary>
		public static float Distance(Vector4 a, Vector4 b) {
			Vector4 d;
			Subtract(ref a, ref b, out d);
			return d.Length();
		}
	}

	public partial struct Vector2 {
		/// <summary>
		/// 距離の2乗
		/// </summary>
		public static float DistanceSquared(Vector2 a, Vector2 b) {
			Vector2 d;
			Subtract(ref a, ref b, out d);
			return d.LengthSquared();
		}

		/// <summary>
		/// 距離の2乗
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void DistanceSquared(ref Vector2 a, ref Vector2 b, out float result) {
			Vector2 d;
			Subtract(ref a, ref b, out d);
			result = d.LengthSquared();
		}
	}

	public partial struct Vector3 {
		/// <summary>
		/// 距離の2乗
		/// </summary>
		public static float DistanceSquared(Vector3 a, Vector3 b) {
			Vector3 d;
			Subtract(ref a, ref b, out d);
			return d.LengthSquared();
		}

		/// <summary>
		/// 距離の2乗
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void DistanceSquared(ref Vector3 a, ref Vector3 b, out float result) {
			Vector3 d;
			Subtract(ref a, ref b, out d);
			result = d.LengthSquared();
		}
	}

	public partial struct Vector4 {
		/// <summary>
		/// 距離の2乗
		/// </summary>
		public static float DistanceSquared(Vector4 a, Vector4 b) {
			Vector4 d;
			Subtract(ref a, ref b, out d);
			return d.LengthSquared();
		}

		/// <summary>
		/// 距離の2乗
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void DistanceSquared(ref Vector4 a, ref Vector4 b, out float result) {
			Vector4 d;
			Subtract(ref a, ref b, out d);
			result = d.LengthSquared();
		}
	}

}
